#include<iostream>
using namespace std;

bool isReverse(string s1, string s2) {
    int len = s1.length();
    for(int i=0; i<len; i++) {
        if(s1[i] != s2[len-i-1])    return false;
    }
    return true;
}

long long dfs(string s1, string s2) {
    if(s1 == s2)    return 1L;
    else if(isReverse(s1, s2))  return 1 << (s1.length()-1);
    else {
        return dfs(s1.substr(1), s2.substr(0, s2.length()-1));
    }
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    cout << dfs(s1, s2) << endl;
    return 0;
} 